package com.candy.th4;

/**
 * @author donglin
 * @Title:
 * @类名: Client
 * @date 2020/7/22
 */
public class Client extends Thread{
    //共享资源（银行账户）
    private Bank bank;
    //想要取款的金额
    private int want;

    public Client(String name, Bank bank, int want) {
        super(name);
        this.bank = bank;
        this.want = want;
    }

    @Override
    public void run() {
        int money;
        //当取款金额大于0时，为正常取款
        while ((money=this.bank.getMoney(want))>0){
            System.out.println(this.getName()+"取到钱了");

        }
        //取款结束后，打印提示
        System.out.println("取款结束");
    }
}
